package com.matt.domain.nursery;

import com.matt.domain.course.CoursePlanClasses;
import com.matt.commons.model.Domain;
import com.matt.foundation.utils.DateUtil;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;

/**
 * *******************************\
 * 托班排课详情记录
 * Created by lch.
 * form com.matt
 * on 2018/11/26
 * *******************************
 */
@Entity
@Table(name = "nursery_schedule_record")
@Data
@EqualsAndHashCode(callSuper = true)
public class NurseryScheduleRecord extends Domain {

    @Column(columnDefinition = "varchar(32) COMMENT '托班排课id'")
    private String nurseryScheduleId;

    @Column(columnDefinition = "varchar(500) COMMENT '活动名称'")
    private String activityContent;

    @Column(columnDefinition = "int default 0 COMMENT '分类 0:非主题课 1:主题课'")
    private Integer category=0;

    @Column(columnDefinition = " datetime COMMENT '开始时间' ")
    private Date beginDate;

    @Column(columnDefinition = " datetime COMMENT '结束时间' ")
    private Date endDate;


    @Column(columnDefinition = "varchar(500) COMMENT '如果是主题课程则存放主题课程ID,否则可能存放资源地址'")
    private String resObj;
    
    @Column(columnDefinition = "varchar(500) COMMENT '活动课备注信息'")
    private String remark;

    @Transient
    private String begin;

    @Transient
    private String end;

    @Transient
    private CoursePlanClasses coursePlanClasses;

    @Transient
    private Integer templateType;

    @Transient
    private String teacherName;

    @Transient
    private String teacherId;

    public static NurseryScheduleRecord of(String nurseryScheduleId,String activityContent,Date beginDate,Date endDate){
        NurseryScheduleRecord vo = new NurseryScheduleRecord();
        vo.setNurseryScheduleId(nurseryScheduleId);
        vo.setActivityContent(activityContent);
        vo.setBeginDate(beginDate);
        vo.setEndDate(endDate);
        return vo;
    }
    
    public static NurseryScheduleRecord ofRemark(String nurseryScheduleId,String activityContent,Date beginDate,Date endDate,String remark){
        NurseryScheduleRecord vo = new NurseryScheduleRecord();
        vo.setNurseryScheduleId(nurseryScheduleId);
        vo.setActivityContent(activityContent);
        vo.setBeginDate(beginDate);
        vo.setEndDate(endDate);
        vo.setRemark(remark);
        return vo;
    }

    public static NurseryScheduleRecord ofDomain(NurserySchedule nurserySchedule, NurseryScheduleRecord nurseryScheduleRecord) {
        NurseryScheduleRecord vo = new NurseryScheduleRecord();
        vo.setNurseryScheduleId(nurserySchedule.getId());
        vo.setCategory(nurseryScheduleRecord.getCategory());
        vo.setActivityContent(nurseryScheduleRecord.getActivityContent());
        vo.setBeginDate(DateUtil.parseToDayHourM(DateUtil.convertStr(new Date())+" "+nurseryScheduleRecord.getBegin()));
        vo.setEndDate(DateUtil.parseToDayHourM(DateUtil.convertStr(new Date())+" "+nurseryScheduleRecord.getEnd()));
        return vo;
    }
    
    public static NurseryScheduleRecord ofRemark(NurserySchedule nurserySchedule, NurseryScheduleRecord nurseryScheduleRecord) {
        NurseryScheduleRecord vo = new NurseryScheduleRecord();
        vo.setNurseryScheduleId(nurserySchedule.getId());
        vo.setCategory(nurseryScheduleRecord.getCategory());
        vo.setActivityContent(nurseryScheduleRecord.getActivityContent());
        vo.setBeginDate(DateUtil.parseToDayHourM(DateUtil.convertStr(new Date())+" "+nurseryScheduleRecord.getBegin()));
        vo.setEndDate(DateUtil.parseToDayHourM(DateUtil.convertStr(new Date())+" "+nurseryScheduleRecord.getEnd()));
        vo.setRemark(nurseryScheduleRecord.getRemark());
        return vo;
    }
}
